package com.gomtel.smartdevice.ui.dialog;

import android.content.Context;
import android.support.annotation.IdRes;
import android.support.annotation.StyleRes;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.gomtel.smartdevice.R;
import com.gomtel.smartdevice.base.WatchBaseDialog;
import com.gomtel.smartdevice.moudle.event.CommonEvent;
import com.gomtel.smartdevice.moudle.event.EventCode;
import com.gomtel.smartdevice.moudle.rxtools.EventBusUtil;
import com.gomtel.smartdevice.utils.LogUtil;
import com.gomtel.smartdevice.utils.SystemUtil;
import com.gomtel.smartdevice.utils.ToastUtil;

import butterknife.BindView;


/**
 * Created by Administrator on 2018/3/21.
 */

public class GenderDialog extends WatchBaseDialog implements View.OnClickListener, RadioGroup.OnCheckedChangeListener {

    private Context context;
    private int status;
    @BindView(R.id.group_view)
    RadioGroup group_view;
    @BindView(R.id.btn_commit)
    Button btn_commit;


    protected GenderDialog(Context context, @StyleRes int themeResId, int status) {
        super(context, themeResId);
        this.context = context;
        this.status = status;
    }

    @Override
    protected int getLayout() {
        return R.layout.dialog_gender_select;
    }

    @Override
    protected void initClass() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initListener() {
        btn_commit.setOnClickListener(this);
        group_view.setOnCheckedChangeListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_commit:
                EventBusUtil.sendEvent(new CommonEvent(EventCode.GENDER, status));
                dismiss();
                break;
        }

    }

    @Override
    public void onCheckedChanged(RadioGroup radioGroup, @IdRes int i) {
        switch (i) {
            case R.id.life:
                status = 0;
                break;
            case R.id.right:
                status = 1;
                break;
        }
        group_view.check(i);
        new ToastUtil(context).showToast("status : " + status);
    }

    @Override
    protected void onDismissListener() {
        super.onDismissListener();
        SystemUtil.windowToLight(context);
    }


}
